package io.renren.htby.utils;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class SocketUtils {
	
	/** 分发系统的标记 */
	public static String DIS_CONFIG_MARK = "DIS_CONFIG_NIO";
	/** 分发系统的开始的状态 */
	public static String DIS_START_STATE = "0";
	/** 分发系统的断线后的状态 */
	public static String DIS_RECONNECT_MANAGE = "1";
	/** NIO服务端的集合 */
	public static Map<String, Object> ServersMap = new HashMap<String, Object>();
	
	/** 分发系统nio服务端的 key */
	public static String DIS_SERVER_KEY = "DIS_SERVER_KEY";
	
	/** 断线重连，间隔时间 interval间隔 */
	public static Integer NIO_RECONNECT_INTERVAL_TIME = 5000;
	/** 断线重连，次数 */
	public static Integer NIO_RECONNECT_TIMES = 5;
	
	
	/** 遍历周期 */
	public static int ctyle = 5 * 1000;
	/** 超时时间 */
	public static int TIME_OUT = 300000;
	/** 等待的命令 */
	public static String WAITING_CODE = "waiting...";
	/** 错误的命令 */
	public static String ERROR_CODE = "error";
	/** 超时的命令 */
	public static String TIMEOUT_CODE = "time_out";
	
	
	/** 控制 端口 */
	public static Integer CTRL_PORT = 9991;
	/** 物联网接口服务 端口 */
	public static Integer IOTS_PORT = 9992;
	/** web端 端口 */
	public static Integer WEB_PORT = 9993;
	/** 分发 端口 */
	public static Integer DIS_PORT = 9994;
	
	@Value("${socket.dis.port}")
	public void setDIS_PORT(String DIS_PORT) {
		SocketUtils.DIS_PORT = Integer.parseInt(DIS_PORT);
	}
	
	@Value("${socket.web.port}")
	public void setWEB_PORT(String WEB_PORT) {
		SocketUtils.WEB_PORT = Integer.parseInt(WEB_PORT);
	}
	
	@Value("${socket.ctrl.port}")
	public void setCTRL_PORT(String CTRL_PORT) {
		SocketUtils.CTRL_PORT = Integer.parseInt(CTRL_PORT);
	}
	
	@Value("${socket.iots.port}")
	public void setIOTS_PORT(String IOTS_PORT) {
		SocketUtils.IOTS_PORT = Integer.parseInt(IOTS_PORT);
	}
}
